<template>
  <section class="app-main">
    <transition name="fade-transform" mode="out-in">
      <keep-alive>
        <m-frame v-if="iframeUrl" :path="iframeUrl"></m-frame>
        <router-view v-else :key="key"/>
      </keep-alive>
    </transition>
  </section>
</template>

<script>
import MFrame from '@/views/iframe/index'

export default {
  name: 'AppMain',
  components: { MFrame },
  computed: {
    iframeUrl () {
      return this.R.path(['meta', 'iframeUrl'], this.$route)
    },
    key () {
      return this.$route.path
    }
  }
}
</script>

<style lang="scss" scoped>
.app-main {
  /* 50= navbar  50  */
  height: 100%;
  width: 100%;
  position: relative;
  padding: 10px;
}

.fixed-header + .app-main {
  padding-top: 50px;
}

.hasTagsView {
  .app-main {
    /* 84 = navbar + tags-view = 50 + 34 */
    height: calc(100vh - 84px);
  }

  .fixed-header + .app-main {
    padding-top: 84px;
  }
}
</style>

<style lang="scss">
// fix css style bug in open el-dialog
.el-popup-parent--hidden {
  .fixed-header {
    padding-right: 15px;
  }
}
</style>
